﻿<Page x:Class="App17.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Controls="using:App17.Controls"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:App17"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d">

    <Page.DataContext>
        <Binding Path="MainPageViewModel">
            <Binding.Source>
                <ViewModels:Locator xmlns:ViewModels="using:App17.ViewModels" />
            </Binding.Source>
        </Binding>
    </Page.DataContext>

    <Page.Resources>

        <Style TargetType="Controls:VariableGridView">
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
            <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
        </Style>

        <Style TargetType="VariableSizedWrapGrid">
            <Setter Property="Orientation" Value="Horizontal" />
            <Setter Property="Width" Value="1366" />
        </Style>

        <DataTemplate x:Name="ItemTemplate">
            <Grid Background="{Binding Brush}">
                <Rectangle Width="1250" Height="500" />
                <Grid VerticalAlignment="Bottom">
                    <Grid.Background>
                        <SolidColorBrush Opacity=".5" Color="Black" />
                    </Grid.Background>
                    <StackPanel Margin="10">
                        <TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="{Binding Name}" />
                    </StackPanel>
                </Grid>
            </Grid>
        </DataTemplate>

    </Page.Resources>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Controls:VariableGridView x:Name="MyGridView"
                                   ItemTemplate="{StaticResource ItemTemplate}"
                                   ItemsSource="{Binding Colors}"
                                   SelectedItem="{Binding Selected, Mode=TwoWay}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <VariableSizedWrapGrid ItemHeight="250" ItemWidth="250" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </Controls:VariableGridView>
    </Grid>

</Page>
